package com.rpay.web.task;

import com.rpay.common.dto.user.UserDTO;
import com.rpay.service.user.IUserIncomeService;
import com.rpay.service.user.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * Title：
 * Description
 *
 * @author fxg06 on 2018/5/8
 * @version 1.0
 */
@Component
public class UserIncomeTask {
    @Autowired
    private IUserService iUserService;
    @Autowired
    private IUserIncomeService iUserIncomeService;


    //每天0点10分执行
    @Scheduled(cron = "0 5 0 * * ? ")
    public void userIncomeCron() {
        List<UserDTO> list = iUserService.getAllUser(null);
        if (!CollectionUtils.isEmpty(list)) {
            for (UserDTO userDTO : list) {
                if ("VALID".equals(userDTO.getStatus())) {
                    iUserIncomeService.updateUserIncome(userDTO.getId());
                }
            }
        }
    }

}
